package com.hyq.market.ui.login;

import com.hyq.market.base.AbsPresenter;
import com.hyq.market.bean.LoginInfo;
import com.hyq.market.bean.UserInfo;
import com.hyq.market.ui.home.HomeAc;
import com.hyq.market.ui.home.mime.ModeUerInfo;

/**
 * Created by Administrator on 2017/7/26 0026.
 */

public class PersenterLogin extends AbsPresenter {
    private  IViewLogin ivew;

    public PersenterLogin(IViewLogin iViewLogin) {
        this.ivew=iViewLogin;
    }

    @Override
    public void getData(Object o) {
        doLogin(o);
    }


    private void doLogin(Object request){
        iMode=new ModeLogin();
        iMode.getData(request,this);
    }


    @Override
    public void netSucceed(Object o, int code) {
       if(o instanceof LoginInfo)
       {
           if (((LoginInfo) o).getStatus()==1){
               getUserInfo();
               ivew.showMsg("登录成功");
           }else {
               ivew.showMsg("登录失败");
           }

       }
       if (o instanceof UserInfo)
       {
           ivew.showMsg("登录成功");
           ivew.startActivity(HomeAc.class);
       }
    }

    private void getUserInfo() {
        iMode=new ModeUerInfo();
        iMode.getData(this);
    }
}
